package org.redr.canvas;

import com.trolltech.qt.gui.QDialog;
import com.trolltech.qt.gui.QHBoxLayout;
import com.trolltech.qt.gui.QLabel;
import com.trolltech.qt.gui.QLineEdit;
import com.trolltech.qt.gui.QPushButton;
import com.trolltech.qt.gui.QTextEdit;
import com.trolltech.qt.gui.QVBoxLayout;
import com.trolltech.qt.gui.QWidget;

public class TemplateDialog extends QDialog {
	private QLineEdit nameEdit;
	private QLineEdit tagsList;
	private QTextEdit descriptionEdit;
	private boolean tagAccepted;

	public TemplateDialog(){
		super();
		setWindowTitle("Save As Template");
		setLayout(new QVBoxLayout());
		QWidget mainWidgetBox = new QWidget();
		mainWidgetBox.setLayout(new QVBoxLayout());
		layout().addWidget(mainWidgetBox);
		mainWidgetBox.layout().addWidget(new QLabel("Set tags as comma (,) delimited list", mainWidgetBox));
		
		QWidget topWidgetBox = new QWidget(mainWidgetBox);
		topWidgetBox.setLayout(new QHBoxLayout());
		mainWidgetBox.layout().addWidget(topWidgetBox);
		
		topWidgetBox.layout().addWidget(new QLabel("Template Name: ", topWidgetBox));
		
		nameEdit	=	new QLineEdit();
		topWidgetBox.layout().addWidget(nameEdit);
		
		topWidgetBox.layout().addWidget(new QLabel("Tags: ", topWidgetBox));
		
		tagsList	=	new QLineEdit();
		topWidgetBox.layout().addWidget(tagsList);
		
		QWidget bottomWidgetBox	=	new QWidget(mainWidgetBox);
		mainWidgetBox.layout().addWidget(bottomWidgetBox);
		
		bottomWidgetBox.setLayout(new QVBoxLayout());
		bottomWidgetBox.layout().addWidget(new QLabel("Description:", bottomWidgetBox));
		
		descriptionEdit = new QTextEdit(bottomWidgetBox);
		bottomWidgetBox.layout().addWidget(descriptionEdit);
		
		QWidget buttonWidgetBox = new QWidget(mainWidgetBox);
		mainWidgetBox.layout().addWidget(buttonWidgetBox);
		buttonWidgetBox.setLayout(new QHBoxLayout());
		
		
		QPushButton okButton = new QPushButton("OK", buttonWidgetBox);
		QPushButton cancelButton = new QPushButton("Cancel", buttonWidgetBox);
		
		okButton.clicked.connect(this, "acceptData(boolean)");
		cancelButton.clicked.connect(this, "rejectData(boolean)");
	}	
	public void acceptData(boolean b){
		tagAccepted = true;
		this.accept();
	}
	
	public void rejectData(boolean b){
		tagAccepted = false;
		this.reject();
	}
		
	
}
